<template>
	<DetailPage v-bind="detailConfig" :model="nowRowData" style="width: 100%; margin: 0 auto">
		<template #bscTaskEvaluatorInfoList>{{ person }}</template>
		<template #dpServiceObjectList>{{ obj }} </template>
		<template #homePractitionerList>{{ person }}</template>
		<template #serviceObjectHomeList>{{ obj }} </template>
		<template #dpServiceOrgBaseList>{{ org }} </template>
		<template #taskTimeRange="{row}">{{nowRowData[row.prop].join("~") }} </template>
	</DetailPage>
</template>

<script setup lang="ts">
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import { detailConfig } from '../config'
import apiMod from '@/apiMod/index'
type Props = {
	nowRowData?: any
}
let props = withDefaults(defineProps<Props>(), {
	nowRowData: {},
})
// 通过接口获取勾选的数据
const getApiSelect = async (editData, api) => {
	if (editData) {
		let list = editData.split(',')
		let params = {
			idList: list,
			pageParaPO: { size: 100000, current: 1 },
			isWithAuth:0
		}
		let res = await apiMod[api](params)
		return res.data.records
	} else {
		return []
	}
}
let person = ref('')
let obj = ref('')
let org = ref('')
watch(()=>props.nowRowData.taskType,(newVal)=>{
	if(newVal){
		console.log('判断',props.nowRowData)
		if(newVal == 1){
			getApiSelect(props.nowRowData.evaluatorIds,'view_dpFoundationPractitioners_page').then(res=>{
			let list = res.map(el=>{
				return el.practitionersName
			})
				person.value = list.join(', ')
			})
			getApiSelect(props.nowRowData.serviceObjectIds,'view_dpServiceObject_page').then(res=>{
				let list = res.map(el=>{
				return el.name
			})
			obj.value = list.join(', ')
			})
		}else if(newVal == 2){
			getApiSelect(props.nowRowData.evaluatorIds,'view_dpFoundationPractitioners_page').then(res=>{
			let list = res.map(el=>{
				return el.practitionersName
			})
				person.value = list.join(', ')
			})
			getApiSelect(props.nowRowData.serviceOrgIds,'view_dpServiceOrgBase_page').then(res=>{
				let list = res.map(el=>{
				return el.organizationName
			})
			org.value = list.join(', ')
			})
		}else if(newVal ==3){
			getApiSelect(props.nowRowData.evaluatorIds,'view_dpFoundationPractitioners_page').then(res=>{
			let list = res.map(el=>{
				return el.practitionersName
			})
				person.value = list.join(', ')
			})
			getApiSelect(props.nowRowData.serviceObjectIds,'view_dpServiceObjectHome_page').then(res=>{
				let list = res.map(el=>{
				return el.name
			})
			obj.value = list.join(', ')
			})
		}
		
		
	}
	
},
{immediate:true,deep:true})
</script>
